<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="text/css">
		body{
			text-align: center;
		}
	</style>
</head>
<body>
	<script type="text/javascript">
		//杨辉三角  输入行数   在页面显示对应的三角
		/*
				1
			1		1
		1	    2      1
	1       3       3      1   4,2 ===> 3,1  3,2
		*///[[1], [1, 1], [1, 2, 1],[1, 3, 3, 1]]
	var num = Number(prompt("请输入行数"))
	var arr = new Array(num)
	for(var i = 0; i < arr.length; i++){
		arr[i] = new Array(i + 1)
		for(var j = 0; j <= i; j++){
			// 第一项和最后一项是1
			if(j == 0 || j == i){
				arr[i][j] = 1
			}else{
				arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j]
			}
			document.write(arr[i][j] + " ")
		}
			document.write("<br>")
	}
	console.log(arr)

	</script>
</body>
</html>